home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 October / PCgo 2008-10 (DVD).iso / interface / js / history.js next >
Encoding:
Text File  |  2007-07-31  |  1.4 KB  |  62 lines

  1. function HistoryItem(html, type, searchString, searchParams) {
  2.   this.htmlPage = html;
  3.   this.searchType = type;
  4.   this.searchString = searchString;
  5.   this.globalSearchParams = searchParams;
  6. }
  7.  
  8. function HistoryMag() {
  9.   this.items = new Array();
  10.   this.position = -1;
  11.   
  12.   this.deleteAllAfterCurrentPosition = function() {
  13.     if (this.position != -1) {
  14.       this.items.length = this.position+1;
  15.     }
  16.     else {
  17.       this.items = new Array();
  18.     }
  19.   }
  20.   
  21.   this.insertItem = function(filename, type, searchString, searchParams) {
  22.     var item = new HistoryItem(filename, type, searchString, searchParams);
  23.     this.deleteAllAfterCurrentPosition();
  24.     this.items.push(item);
  25.     if (this.position == -1) {
  26.       this.moveFirst();
  27.     }
  28.     else {
  29.       this.position = this.items.length-1;
  30.     }
  31.   }
  32.  
  33.   this.getItem = function() {
  34.     if (this.position != -1) {
  35.       var item = this.items[this.position];
  36.       return new Array(item.htmlPage, item.searchType, item.searchString, item.globalSearchParams);
  37.     }
  38.     else {
  39.       return null;
  40.     }
  41.   }
  42.  
  43.   this.moveFirst = function() {
  44.     if (this.items.length > 0) {
  45.       this.position = 0;
  46.     }
  47.   }
  48.   
  49.   this.movePrev = function() {
  50.     if (this.position > 0) {
  51.       this.position--;
  52.     }  
  53.   }
  54.   
  55.   this.moveNext = function() {
  56.     if (this.position < this.items.length-1) {
  57.       this.position++;
  58.     }    
  59.   }
  60.   
  61. }
  62.